﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GG.Base;
using System.Diagnostics;

namespace GGSim
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
        internal static MainWindow instance;
        public static GameControl control;

        public MainWindow()
        {
            instance = this;
            this.InitializeComponent();

            this.KeyDown += new KeyEventHandler(MainWindow_KeyDown);
            control = new GameControl(isoGrid);
            isoGrid.cameraControl.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(cameraControl_PropertyChanged);
            zoomSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(zoomSlider_ValueChanged);

        }

        void MainWindow_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.Left: isoGrid.TurnLeft(); break;
                case Key.Right: isoGrid.TurnRight(); break;
                case Key.Space: isoGrid.SwitchTopDown(isoGrid.LookOrientation + 45); break;
            }
        }

        void zoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            zoomLabel.Content = zoomSlider.Value + "X";
            isoGrid.cameraControl.Zoom = zoomSlider.Value;
        }

        void cameraControl_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Zoom")
            {
                zoomSlider.Value = isoGrid.cameraControl.Zoom;
                zoomLabel.Content = isoGrid.cameraControl.Zoom + "X";
            }
        }

	}
}